/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ClasificacionDePizzasBaseClassificationBox.java
 *
 * Created on 11-ene-2010, 12:07:59
 */
package clasificaciondepizzas;

import clasificaciondepizzas.chart.BaseChart;
import clasificaciondepizzas.classification.EvaluatorBase;
import org.jfree.chart.ChartPanel;

/**
 *
 * @author Manuel
 */
public class ClasificacionDePizzasBaseClassificationBox extends javax.swing.JDialog {

    /** Creates new form ClasificacionDePizzasBaseClassificationBox */
    public ClasificacionDePizzasBaseClassificationBox(java.awt.Frame parent, double roundness, double eccentricity, double areaRatio, double aspectRatio) {
        super(parent);
        this.roundness = roundness;
        this.eccentricity = eccentricity;
        this.areaRatio = areaRatio;
        this.aspectRatio = aspectRatio;
        initComponents();
        showChart();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        chartInternalFrame = new javax.swing.JInternalFrame();
        roundnessWeightLabel = new javax.swing.JLabel();
        roundnessWeightComboBox = new javax.swing.JComboBox();
        eccentricityWeightLabel = new javax.swing.JLabel();
        eccentricityWeightComboBox = new javax.swing.JComboBox();
        areaRatioWeightLabel = new javax.swing.JLabel();
        areaRatioWeightComboBox = new javax.swing.JComboBox();
        aspectRatioWeightLabel = new javax.swing.JLabel();
        aspectRatioWeightComboBox = new javax.swing.JComboBox();
        baseTypeLabel = new javax.swing.JLabel();
        appBaseTypeLabel = new javax.swing.JLabel();
        classifyButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setName("Form"); // NOI18N

        chartInternalFrame.setName("chartInternalFrame"); // NOI18N
        chartInternalFrame.setVisible(true);

        javax.swing.GroupLayout chartInternalFrameLayout = new javax.swing.GroupLayout(chartInternalFrame.getContentPane());
        chartInternalFrame.getContentPane().setLayout(chartInternalFrameLayout);
        chartInternalFrameLayout.setHorizontalGroup(
            chartInternalFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 380, Short.MAX_VALUE)
        );
        chartInternalFrameLayout.setVerticalGroup(
            chartInternalFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 156, Short.MAX_VALUE)
        );

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(clasificaciondepizzas.ClasificacionDePizzasApp.class).getContext().getResourceMap(ClasificacionDePizzasBaseClassificationBox.class);
        roundnessWeightLabel.setText(resourceMap.getString("roundnessWeightLabel.text")); // NOI18N
        roundnessWeightLabel.setName("roundnessWeightLabel"); // NOI18N

        roundnessWeightComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" }));
        roundnessWeightComboBox.setName("roundnessWeightComboBox"); // NOI18N

        eccentricityWeightLabel.setText(resourceMap.getString("eccentricityWeightLabel.text")); // NOI18N
        eccentricityWeightLabel.setName("eccentricityWeightLabel"); // NOI18N

        eccentricityWeightComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" }));
        eccentricityWeightComboBox.setName("eccentricityWeightComboBox"); // NOI18N

        areaRatioWeightLabel.setText(resourceMap.getString("areaRatioWeightLabel.text")); // NOI18N
        areaRatioWeightLabel.setName("areaRatioWeightLabel"); // NOI18N

        areaRatioWeightComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" }));
        areaRatioWeightComboBox.setName("areaRatioWeightComboBox"); // NOI18N

        aspectRatioWeightLabel.setText(resourceMap.getString("aspectRatioWeightLabel.text")); // NOI18N
        aspectRatioWeightLabel.setName("aspectRatioWeightLabel"); // NOI18N

        aspectRatioWeightComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" }));
        aspectRatioWeightComboBox.setName("aspectRatioWeightComboBox"); // NOI18N

        baseTypeLabel.setText(resourceMap.getString("baseTypeLabel.text")); // NOI18N
        baseTypeLabel.setName("baseTypeLabel"); // NOI18N

        appBaseTypeLabel.setText(resourceMap.getString("appBaseTypeLabel.text")); // NOI18N
        appBaseTypeLabel.setName("appBaseTypeLabel"); // NOI18N

        classifyButton.setText(resourceMap.getString("classifyButton.text")); // NOI18N
        classifyButton.setName("classifyButton"); // NOI18N
        classifyButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                classifyButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(chartInternalFrame)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(baseTypeLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(appBaseTypeLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 285, Short.MAX_VALUE)
                        .addComponent(classifyButton))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(roundnessWeightComboBox, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(roundnessWeightLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(eccentricityWeightComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(eccentricityWeightLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(areaRatioWeightLabel)
                            .addComponent(areaRatioWeightComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(aspectRatioWeightComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(aspectRatioWeightLabel))
                        .addGap(13, 13, 13)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(chartInternalFrame)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE, false)
                            .addComponent(roundnessWeightLabel)
                            .addComponent(eccentricityWeightLabel))
                        .addGap(7, 7, 7)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE, false)
                            .addComponent(eccentricityWeightComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(roundnessWeightComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(baseTypeLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(appBaseTypeLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 12, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE, false)
                            .addComponent(areaRatioWeightLabel)
                            .addComponent(aspectRatioWeightLabel))
                        .addGap(7, 7, 7)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE, false)
                            .addComponent(areaRatioWeightComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(aspectRatioWeightComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 9, Short.MAX_VALUE)
                        .addComponent(classifyButton)))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void classifyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_classifyButtonActionPerformed
        EvaluatorBase eb = new EvaluatorBase(roundnessWeightComboBox.getSelectedIndex() + 1, eccentricityWeightComboBox.getSelectedIndex() + 1, areaRatioWeightComboBox.getSelectedIndex() + 1, aspectRatioWeightComboBox.getSelectedIndex() + 1);
        String baseType = eb.pizzaCalculate(roundness, eccentricity, areaRatio, aspectRatio);
        appBaseTypeLabel.setText(baseType);
    }//GEN-LAST:event_classifyButtonActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel appBaseTypeLabel;
    private javax.swing.JComboBox areaRatioWeightComboBox;
    private javax.swing.JLabel areaRatioWeightLabel;
    private javax.swing.JComboBox aspectRatioWeightComboBox;
    private javax.swing.JLabel aspectRatioWeightLabel;
    private javax.swing.JLabel baseTypeLabel;
    private javax.swing.JInternalFrame chartInternalFrame;
    private javax.swing.JButton classifyButton;
    private javax.swing.JComboBox eccentricityWeightComboBox;
    private javax.swing.JLabel eccentricityWeightLabel;
    private javax.swing.JComboBox roundnessWeightComboBox;
    private javax.swing.JLabel roundnessWeightLabel;
    // End of variables declaration//GEN-END:variables
    private double roundness;
    private double eccentricity;
    private double areaRatio;
    private double aspectRatio;

    public void showChart() {
        EvaluatorBase eb = new EvaluatorBase(roundnessWeightComboBox.getSelectedIndex() + 1, eccentricityWeightComboBox.getSelectedIndex() + 1, areaRatioWeightComboBox.getSelectedIndex() + 1, aspectRatioWeightComboBox.getSelectedIndex() + 1);
        String baseType = eb.pizzaCalculate(roundness, eccentricity, areaRatio, aspectRatio);
        appBaseTypeLabel.setText(baseType);
        BaseChart base = new BaseChart(roundness, eccentricity, areaRatio, aspectRatio);
        ChartPanel bpanel = new ChartPanel(base.getChart());
        bpanel.setVisible(true);
        chartInternalFrame.setContentPane(bpanel);
    }
}
